package com.hxtec.polaris.controller;

import com.hxtec.polaris.service.GoodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Describtion 商品相关
 * @Author yonyong
 * @Date 2019/11/12 13:58
 * @Version 1.0.0
 **/
@RestController
@RequestMapping(value = "goods",produces = "application/json;charset=utf-8")
@CrossOrigin
@Api(value = "/goods", tags = "商品相关")
public class GoodsController {

    @Autowired
    private GoodService goodService;

    /**
     * 获取商品列表
     * @return
     */
    @ApiOperation("获取商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "起始页", required = false, dataType = "String"),
            @ApiImplicitParam(name = "rows", value = "查询条数", required = false, dataType = "String"),
            @ApiImplicitParam(name = "order", value = "排序条件", required = false, dataType = "String"),
    })
    @GetMapping("getAll")
    public Object getAllGoods(String page,String rows,String order){
        return goodService.getAllGoods(page,rows,order);
    }

    /**
     * 获取猜你喜欢数据
     * @return
     */
    @ApiOperation("获取猜你喜欢商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "起始页", required = false, dataType = "String"),
            @ApiImplicitParam(name = "rows", value = "查询条数", required = false, dataType = "String"),
            @ApiImplicitParam(name = "order", value = "排序条件", required = false, dataType = "String"),
    })
    @GetMapping("getLike")
    public Object getLikeGoods(String page,String rows,String order){
        return goodService.getGuessLikeGoods(page,rows,order);
    }

    /**
     * 获取分类精选数据
     * @return
     */
    @ApiOperation("获取分类精选商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "起始页", required = false, dataType = "String"),
            @ApiImplicitParam(name = "rows", value = "查询条数", required = false, dataType = "String")
    })
    @GetMapping("getGroupSelect")
    public Object getGroupSelect(String page,String rows){
        return goodService.getClassifiedSelectGoods(page,rows);
    }

    /**
     * 获取某个分类下的商品列表
     * @return
     */
    @ApiOperation("获取某个分类下的商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "起始页", required = false, dataType = "String"),
            @ApiImplicitParam(name = "rows", value = "查询条数", required = false, dataType = "String"),
            @ApiImplicitParam(name = "cid", value = "分类id", required = false, dataType = "String"),
            @ApiImplicitParam(name = "order", value = "排序条件", required = false, dataType = "String"),
    })
    @GetMapping("getGroup")
    public Object getGroup(String page,String rows,String cid,String order){
        return goodService.getTargrtGroupGoods(page,rows,cid,order);
    }
}
